AddCSLuaFile("cl_init.lua");
AddCSLuaFile("shared.lua");
include("shared.lua");


function ENT:Initialize()
	
	self:SetModel("models/nintendo/Mother/Pigmask.mdl");
	//self:SetModel("models/player/kleiner.mdl");
	self:SetColor(255, 255, 255, 255);
	self:DrawShadow(false);
	
end

function ENT:SetPlayer(ply)
	self:SetNWEntity("UCPlayer", ply);
end

function ENT:GetPlayer()
	return self:GetNWEntity("UCPlayer");
end


local pp = {
	"aim_yaw",
	"move_yaw",
	"head_pitch"
};

function ENT:Think()
	
	if (ValidEntity(self:GetPlayer())) then
		self:SetPos(self:GetPlayer():GetPos());
		self:SetAngles(self:GetPlayer():GetAngles());
	end
	
	local ply = self:GetPlayer();
	
	local seq = ply:GetSequence();
	
	if (seq == ply:LookupSequence("jump")) then
		seq = ply:LookupSequence("jump2");
	end
	
	if (ply:GetNWBool("Taunting", false)) then
		self:DrawShadow(true);
		seq = self:LookupSequence("taunt");
		if (ply:GetNWInt("PigRank") == 4) then
			seq = self:LookupSequence("taunt2");
		else
			self:SetPlaybackRate(1.6);
		end
	else
		if (!ply:GetNWBool("UCScared")) then
			self:DrawShadow(false);
		end
	end
	
	self:ResetSequence(seq);
	
	/*if (ply:IsOnGround()) then
		if (self:GetCycle() > .9) then
			//self:SetCycle(.99);
		end
	end*/
	
	for i = 1, #pp do
		local p = ply:GetPoseParameter(pp[i]);
		self:SetPoseParameter(pp[i], p);
	end
	
	self:NextThink(CurTime());
	return true;
	
end
